package com.trendata.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.trendata.dao.ILikeDao;
import com.trendata.domain.Like;

@Service("service")
public class LikeService {

	@Autowired
	private ILikeDao likeDao;

	public void insert(Like like) {
		likeDao.insert(like);
	}

	public int deleteById(long id) {
		return likeDao.deleteById(id);
	}

	public int deleteByImageId(long imageId) {
		return likeDao.deleteByImageId(imageId);
	}

	public Like selectById(long id) {
		return likeDao.selectById(id);
	}

	public List<Like> selectByImageId(long imageId) {
		return likeDao.selectByImageId(imageId);
	}

	public int selectCountByImageId(long imageId) {
		return likeDao.selectCountByImageId(imageId);
	}

	public Like selectByImageIdAndUserOpenId(long imageId, String userOpenId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("imageId", imageId);
		map.put("userOpenId", userOpenId);
		return likeDao.selectByImageIdAndUserOpenId(map);
	}
}
